/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package queenb.web.controller;



import org.apache.log4j.Logger;


import queenb.web.util.ContextUtil;

/**
 *
 * @author Thanh Luan
 */
public class SearchController extends QueenbController {

    private static Logger logger = Logger.getLogger(SearchController.class);
    // Thanh Luan Start Create 15/05/2012

    private String idSearch;
    private String flag;


    public SearchController() {

      
    }

    public void searchAlpha() {
        try {
            String search = ContextUtil.getRequestParameter("idSearch");
            idSearch = search;
            if (search != null && search.contains("ALL")) {
                idSearch = null;
               
            }
            getLogin().setCharacter(idSearch);
        } catch (Exception ex) {
            setIdSearch("ALL");
            getLogin().setCharacter(null);
        }


    }
    
    public String searchAlphaString() {
        try {
            String search = ContextUtil.getRequestParameter("idSearch");
            idSearch = search;
            if (search != null && search.toLowerCase().contains("all")) {
                idSearch = "";
            }
            getLogin().setCharacter(idSearch);
            return  getLogin().getCharacter();
        } catch (Exception ex) {
            setIdSearch("");
            try {
                 getLogin().setCharacter("");
            } catch (Exception e) {
            }
           
            return getIdSearch();
        }


    }
    
    public String searchAlpha_KHCN() {
        try {
            String search = ContextUtil.getRequestParameter("idSearch");
            idSearch = search;
            if (search != null && search.contains("ALL")) {
                idSearch = null;
            }
            getLogin().setCharacter(idSearch);
            return  getLogin().getCharacter();
        } catch (Exception ex) {
            setIdSearch(null);
            try {
                 getLogin().setCharacter(null);
            } catch (Exception e) {
            }
           
            return getIdSearch();
        }


    }

    /**
     * @return the idSearch
     */
    public String getIdSearch() {
        return idSearch;
    }

    /**
     * @param idSearch the idSearch to set
     */
    public void setIdSearch(String idSearch) {
        this.idSearch = idSearch;
    }

    /**
     * @return the flag
     */
    public String getFlag() {
        return flag;
    }

    /**
     * @param flag the flag to set
     */
    public void setFlag(String flag) {
        this.flag = flag;
    }


}
